<script setup lang="ts">
import { ref } from 'vue'
import { dataTransforma,BleWrite } from '@/utils/utils'
const val = ref(false)
const direct = ref()
const props = defineProps<{
  deviceId: string
}>()
const back = () => {
  
  uni.navigateBack({
    delta: 1,
  })
} 

const manualCalibrate= () => {
  dataTransforma('TAOSI',direct.value)
  BleWrite(props.deviceId, '0003CDD0-0000-1000-8000-00805F9B0131', '0003CDD2-0000-1000-8000-00805F9B0131', direct.value)
}



</script>
<template>
  <view class="content">
    <view class="title">
      <u-icon name="arrow-left" color="#ffff" size="22" @click="back"></u-icon>
      设备校准</view>
    <view class="require">
      <view style="font-size: 38.462rpx; margin: 57.692rpx 0 38.462rpx; font-weight: 700"
        >校准现场要求</view
      >
      <view> 1.平展监护气垫，使监护气垫正常鼓起，连接到睡眠监护仪主机; </view>
      <view> 2.监护气垫铺设在床单或床垫下(床垫厚度在10厘米以内); </view>
      <view> 3.床上无人，不能有日常被褥外重物: </view>
      <view> 4.主机连通电源，开机自检3秒后，2分钟内蓝牙绑定，校准参数。 </view>
      <view> ※打开手机蓝牙并授予小程序蓝牙权限。 </view>
    </view>
    <view class="auto-calibrate">
      <view>自动校准</view>
      <u-switch v-model="val" activeColor="#37db58"></u-switch>
    </view>
    <view>
      <u-button type="primary" shape="circle" color="#3780A6" v-if="val"  @click="manualCalibrate"  >{{
         '开始校准'
      }}</u-button>
    </view>
  </view>
</template>
<style lang="scss">
page {
  height: 100%;
  font-family: PingFangSC-regular;
  .content {
    height: 100%;
    background: url(@/static/starry2.png) no-repeat;
    background-size: contain;
    padding: 115.385rpx 48.077rpx 0;
    .title {
      position: relative;
      padding-top: 115.385rpx;
      padding-bottom: 28.846rpx;
      font-size: 34.615rpx;
      color: #ffff;
      text-align: center;
      .u-icon {
        position: absolute;
        left: 3%;
      }
    }
    .require {
      font-size: 30.769rpx;
      line-height: 48.077rpx;
    }
    .auto-calibrate {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 19.231rpx 19.231rpx;
      margin: 28.846rpx 0 96.154rpx;
      border: 3.846rpx solid #e1e1e1;
      border-radius: 19.231rpx;
      font-size: 30.769rpx;
      line-height: 30.769rpx;
    }
  }
}
</style>
